<template>
  <div>
        <van-nav-bar class="app-nav-bar" title="请假列表" left-arrow @click-left="onClickLeft"/>
        <!-- <el-input type="date" style="width: 200px;" placeholder="请输入内容" clearable v-model="form.date"></el-input> -->
        <el-button size="mini" value-format="yyyy-MM-dd" class="btncolor" type="success" @click="qj">快捷请假申请</el-button>
        <van-cell>请假日期：
            <el-date-picker type="date" placeholder="请选择请假日期" v-model="checkDate"></el-date-picker>
            <el-button style="margin-left: 5px;" size="mini" type="primary" icon="el-icon-search" @click="getUser">搜索</el-button>
        </van-cell>
        <el-table
        :data="tableData"
        style="width: 100%">
        <el-table-column
            prop="id"
            label="序号" width="50px">
        </el-table-column>
        <el-table-column
            prop="studentNo"
            label="学号" width="70px">
        </el-table-column>
        <el-table-column
            prop="className"
            label="班级" width="50px">
        </el-table-column>
        <el-table-column
            prop="studentName"
            label="学生姓名">
        </el-table-column>
        <el-table-column
            prop="leaveType"
            label="请假类型">
            <template slot-scope="scope">
                <span style="margin-left:10px" v-if="scope.row.leaveType ==='1'">事假</span>
                <span style="margin-left:10px" v-if="scope.row.leaveType ==='2'">病假</span>
            </template>
        </el-table-column>
        <el-table-column
            prop="modifyTime"
            label="请假时间">
        </el-table-column>
        <el-table-column
            prop="status"
            label="状态">
            <template slot-scope="scope">
                <span style="margin-left:10px" v-if="scope.row.status ==='2'">班主任审核通过</span>
                <span style="margin-left:10px" v-if="scope.row.status ==='3'">家长确认通过</span>
            </template>
        </el-table-column>
        <el-table-column label="操作">
            <template slot-scope="scope">
                <el-button type="success" class="btncolor" size="mini" @click="xq( scope.row)">详情</el-button>
            </template>
        </el-table-column>
        </el-table>

  </div>
</template>

<script>
export default {
data(){
        return{
            tableData:[],
            checkDate:"",
        }
    },
    methods:{
        onClickLeft(){
            this.$router.go(-1) 
        },
        qj(){
            this.$router.push({name: 'TeaApply', params: { id:2}})
        },
        xq(row){
            this.$router.push({name: 'LeaveDetail', params: { id: row.id}})
        },
        async getUser(){
            console.log(this.checkDate);
            // var now = new Date();
            // var getTimeFromDate = function (date) {
            //     return date.toTimeString().slice(0, 8).split(":").join("");//去掉分号
            // };
            // var checkDate = getTimeFromDate(new Date(now.getTime() - 1000));//现在的时间
            // http://122.112.218.153:9004/app/Leave/getLeaveByAccId?accountId=2&tokenPrefix=appuser&leaveDate=
            const {data:res} =await this.request("app/Leave/getLeaveByAccId?accountId=2&tokenPrefix=appuser&leaveDate="+this.checkDate);
            console.log(res)
            this.tableData=res.data
        },
    },created(){
        this.getUser();
    }
}
</script>

<style>
.el-table .cell {
    line-height: 23px !important;
    padding-right: 10px;
}
.el-table td.is-center, .el-table th.is-center {
    text-align: center !important;
}
</style>